<template>
  <div>
    <div v-for="item in menu" :key="item.id">
      <el-submenu :index="item.path" v-if="item.children?.length">
        <template slot="title">
          <i :class="item.meta.icon"></i>
          <span>{{item.meta.name}}</span>
        </template>
        <slot :children="item.children"></slot>
      </el-submenu>
      <el-menu-item :index="item.path" v-else @click="handleSaveMenuPath(item.path)">
        <i :class="item.meta.icon"></i>
        <span>{{item.meta.name}}</span>
      </el-menu-item>
    </div>
  </div>
</template>

<script>
export default {
  props: ["menu"],
  created () {
  },
  methods: {
    handleSaveMenuPath (path) {
      sessionStorage.activePath = path
    }
  },
}
</script>

<style lang="less" scoped>
</style>